Semaphore system based on process events

ABSTRACT

A method and apparatus are described for a semaphore system based on process events. The system may have multiple processes; one or more shared resources; and a semaphore system corresponding to each of the processes. When multiple processes simultaneously request access to a given shared resource, each semaphore system arbitrates on behalf of its corresponding process. In one embodiment, a semaphore system is self-contained and can arbitrate for its corresponding process based on the other process&#39;s events. In another embodiment, the semaphore system interacts with a global arbiter to resolve conflicts.

COPYRIGHT NOTICE

[0001] A portion of the disclosure of this patent document containsmaterial which is subject to copyright protection. The copyright ownerhas no objection to the facsimile reproduction by anyone of the patentdocument or the patent disclosure as it appears in the Patent andTrademark Office patent file or records, but otherwise reserves allcopyright rights whatsoever. The following notice applies to thesoftware and data as described below and in the drawings hereto:Copyright © 2001, Intel Corporation, All Rights Reserved.

FIELD OF THE INVENTION

[0002] The invention relates generally to parallel processes, and moreparticularly, to semaphores for managing access to shared systemresources.

BACKGROUND OF THE INVENTION

[0003] Systems that perform parallel processing comprise simultaneouslyexecuting processes. A common problem when using parallel processing isprotecting the contents of a common resource.

[0004] One known way to implement this is to use a semaphore, which isgenerally a hardware or software flag. In multitasking systems, asemaphore is a variable that indicates the status of a common resource.It is used to lock the resource that is being used. A process needingthe resource checks the semaphore to determine the resource's status andthen decides how to proceed. A semaphore indicates to other potentialusers that a file or other resource is in use and prevents access bymore than one process.

[0005] However, when multiple processes need access to a commonresource, problems such as starvation and/or deadlock may occur.Starvation occurs when one or more processes are prevented fromaccessing the common resource, and deadlock may occur when one or moreprocesses lock each other, thereby stopping execution.

[0006] This is further complicated when there are multiple resources.The classical approach to solving this problem is to implement asemaphore for each resource. However, when the number of resourcesbecomes very large, this solution is not very effective.

BRIEF DESCRIPTION OF THE DRAWINGS

[0007] The present invention is illustrated by way of example, and notby way of limitation, in the figures of the accompanying drawings and inwhich like reference numerals refer to similar elements and in which:

[0008]FIG. 1 is a block diagram illustrating a system architecture inaccordance with general embodiments of the invention.

[0009]FIG. 2 is a block diagram illustrating a prior art system forusing semaphores.

[0010]FIG. 3 is a block diagram illustrating a system havingself-contained semaphore system in accordance with embodiments of theinvention.

[0011]FIG. 4 is a block diagram illustrating a self-contained semaphoresystem in one embodiment of the invention.

[0012]FIG. 5 is a flowchart illustrating a method for using theself-contained semaphore system of FIG. 4.

[0013]FIG. 6 is a block diagram illustrating a self-contained semaphoresystem having a timer element in another embodiment of the invention.

[0014]FIG. 7 is a flowchart illustrating a method for using theself-contained semaphore system of FIG. 6.

[0015]FIG. 8 is a block diagram illustrating a system having semaphoresystem that interacts with a global arbiter in accordance withembodiments of the invention.

[0016]FIG. 9 is a block diagram illustrating a global priority queue ofthe global arbiter of FIG. 8.

[0017]FIG. 10 is a block diagram illustrating a semaphore system thatinteracts with a global arbiter in one embodiment of the invention.

[0018]FIG. 11 is a sample flow diagram of how the global priority queueof the global arbiter in FIG. 8 operates.

[0019]FIG. 12 is a flowchart illustrating a method for the semaphoresystem of FIG. 10.

[0020]FIG. 13 is a block diagram illustrating a semaphore system havinga timer element, and that interacts with a global arbiter in oneembodiment of the invention.

[0021]FIG. 14 is a flowchart illustrating a method for the semaphoresystem of FIG. 13.

[0022]FIG. 15 is a block diagram illustrating a sample logic circuit forthe semaphore system in accordance with general embodiments of theinvention.

DETAILED DESCRIPTION OF THE INVENTION

[0023] In one aspect of the invention is a method for a fairness-basedsemaphore system for managing access to shared system resources. Themethod comprises requesting a resource, and then determining if thatresource is being requested by another process, or if that resource islocked by another process. If it is being requested by another process,then the resource is given to the process having a higher priority. Ifthe resource is locked by another process, then the process is notgranted access to the resource.

[0024] In variations and different embodiments, the semaphore system maycomprise and use any combination of a timer element and a global arbiterhaving a global priority block.

[0025] The present invention includes various operations, which will bedescribed below. The operations of the present invention may beperformed by hardware components or may be embodied inmachine-executable instructions, which may be used to cause ageneral-purpose or special-purpose processor or logic circuitsprogrammed with the instructions to perform the operations.Alternatively, the operations may be performed by a combination ofhardware and software.

[0026] The present invention may be provided as a computer programproduct which may include a machine-readable medium having storedthereon instructions which may be used to program a computer (or otherelectronic devices) to perform a process according to the presentinvention. The machine-readable medium may include, but is not limitedto, floppy diskettes, optical disks, CD-ROMs (Compact Disc-Read OnlyMemories), and magneto-optical disks, ROMs (Read Only Memories), RAMs(Random Access Memories), EPROMs (Erasable Programmable Read OnlyMemories), EEPROMs (Electromagnetic Erasable Programmable Read OnlyMemories), magnetic or optical cards, flash memory, or other type ofmedia/machine-readable medium suitable for storing electronicinstructions.

[0027] Moreover, the present invention may also be downloaded as acomputer program product, wherein the program may be transferred from aremote computer (e.g., a server) to a requesting computer (e.g., aclient) by way of data signals embodied in a carrier wave or otherpropagation medium via a communication link (e.g., a modem or networkconnection). Accordingly, herein, a carrier wave shall be regarded ascomprising a machine-readable medium.

[0028] Introduction

[0029]FIG. 1 illustrates a system 100 in which embodiments of theinvention may be implemented. It comprises at least one CPU (centralprocessing unit) 102 (only one shown), at least one memory 104 (only oneshown), and a bus 106 through which the CPU 102 and memory 104 interact.The memory 104 comprises a plurality of resources 108 (only one shown),and a plurality of semaphores 110 (only one shown), and the CPU 102comprises a plurality of processes 112 (only one shown).

[0030]FIG. 2 illustrates a prior art system 200 that that may beimplemented in the system 100 of FIG. 1. In the system 200, the CPU 102comprises a plurality of processes 202, 204, 206, and plurality ofresources 208, 210, 212, 214, where each resource 208, 210, 212, 214 hasa corresponding semaphore 216, 218, 220, 222 for managing shared accessto the resources 208, 210, 212, 214. Alternatively, each resource 208,210, 212, and 214 may correspond to the semaphore functionality ofsemaphores 216, 218, 220, 222 represented by a single semaphore object224, rather than as separate semaphore objects 216, 218, 220, 222.

[0031] In a prior art embodiment, when a first process 202, 204, 206wants to access a resource 208, 210, 212, 214, the first process 202,204, 206 checks the status of the desired resource 208, 210, 212, 214 bysending a read command over the system bus 106 to the resource's208,210, 212, 214 corresponding semaphore 216, 218, 220, 222. If thedesired resource 208, 210, 212, 214 is available, then the first process202, 204, 206 sends a write command to the corresponding semaphore 216,218, 220, 222 to change the status of the semaphore 216, 218, 220, 222from unlocked to locked.

[0032] In embodiments of the invention, a system is described in whichsemaphores are associated with a process rather than a resource. When asemaphore is locked, it indicates the unavailability of a specifiedresource for the semaphore's corresponding process. When the semaphoreis unlocked, it indicates that its corresponding process is notcurrently using any resource.

[0033] The semaphore may be changed by the occurrence of one or moreevents associated with its corresponding process. A semaphore systemdetects the occurrence of these events and controls the status of thesemaphore. In one embodiment, the semaphore systems are self-containedin that a first semaphore system arbitrates on behalf of a first processby communicating with a second semaphore that arbitrates on behalf of asecond process. In another embodiment, the semaphore systems arbitratefor their respective processes, but are dependent upon a global arbiterfor conflict arbitration processing. These embodiments are furtherdescribed below.

[0034] Self-Contained Semaphore

[0035] In one embodiment of the invention, as illustrated in the system300 of FIG. 3, the CPU 102 comprises a plurality of processes 302, 304,306, and the memory 104 comprises a plurality of resources 308, 310,312, 314, and semaphore system 316, 318, 320. In the system 300, eachprocess 302, 304, 306 has a corresponding semaphore system 316, 318, 320for managing shared access to the resources 308, 310, 312, 314.Alternatively, a single semaphore system 324 can be shared by allprocesses.

[0036] In the descriptions below, processes 302, 304, semaphore systems316, 318, and resource 308 are depicted to illustrate the arbitrationprocess for two processes and their corresponding semaphore systems fora given resource 308. However, one of ordinary skill in the art wouldunderstand that the descriptions apply process 306, semaphore system320, and resource 310, 312, 314, and any other processes, semaphoresystems, and resources that may be defined, but are not illustrated ordiscussed herein.

Semaphore Comprising Local Priority Block

[0037]FIG. 4 illustrates processes 302, 304 having correspondingsemaphore systems 316, 318. Each of the semaphore systems 316, 318comprises a semaphore 400 to indicate the availability or unavailabilityof a resource, and a local arbiter 402 that arbitrates for access to agiven resource 308 on behalf of its corresponding process 302, 304 bymonitoring events of its corresponding process 302, 304 to determine thestatus of the semaphore 400.

[0038] In one embodiment, a semaphore system 316, 318 may additionallycomprise a local priority block 404 that has a fixed priority for itscorresponding process 302, 304. Each process 302, 304 is assigned afixed priority that gives a first process higher or lower priority thana second process. If more than one process 302, 304 requests the sameresource 308 the local arbiter 402 resolves the conflict by giving theresource 308 to the process 302, 304 with the higher priority. Forexample, of process P1 has priority=1 and process P2 has priority=2,where 1 is a higher priority than 2, then if processes P1 and P2simultaneously request a given resource R, the local arbiter 402 willgrant process P1 resource R because P1 has a higher priority than P2.

[0039]FIG. 5 illustrates a method of the above-described embodiment. Itstarts at block 500 and continues to block 502 where it is determined ifthere is a conflict between process P1 and process P2 over a resource R(i.e., does P1's request I.D. equal P2's request I.D.?). If there is aconflict, then it is determined if P1's local priority is greater thanP2's local priority at block 504. If P1's local priority is greater thanP2's local priority, then access is granted to P1 at block 508.Otherwise access is denied to P1 at block 512.

[0040] If there is no conflict, then it is determined if the resource Ris locked by P2 (i.e., if P1's request I.D. does not equal P2's requestI.D., then does P1's request I.D. equal P2's currently locked I.D.?) atblock 506, and if P2 has released its lock on R at block 510. If R islocked by P2, and P2 has released its lock on R, then access to resourceR is granted to P1 at block 508. If R is locked and P2 has not releasedits lock on R, then P1 is denied access to R at block 512. If there isno conflict, and the resource R is not locked by P2, then access toresource R is granted to P1 at block 508. The method ends at block 514.

Semaphore Comprising Local Arbiter Plus Timer Element

[0041] In yet another embodiment, as illustrated in FIG. 6, a semaphoresystem 316, 318 may comprise the local arbiter 402, plus a timer element600. Each semaphore system 316, 318 may comprise a local priority block404, as discussed above, as well as a timer element 600 that keeps trackof the time that its corresponding process 302, 304 has waited for agiven resource 308 without locking its semaphore.

[0042] In one embodiment, the timer 600 is purely time-based, where itcounts the number of clock cycles that have passed since the request fora lock was given. In another embodiment, the timer 600 is a counter thatdetermines which other processes have been granted access to the sameshared resource as the one its corresponding process is requesting. Inthe latter embodiment, the timer 600 is incremented every time anotherprocess is granted access, and reset (for example, to 0) when its ownprocess is granted access.

[0043] In this embodiment, the local arbiter 402 grants a first processaccess if it has been waiting longer than a second process. For example,if the process P1 having priority=1 has been waiting longer than aprocess P2 having priority=2, then the local arbiter grants process P1access. If process P2 has been waiting longer than process P1, then thelocal arbiter grants process P2 access. If both processes have beenwaiting an equal amount of time, then the local arbiter determines whichprocess has the higher priority, and grants the process with the higherpriority access. In this case, that is process P1.

[0044] A method illustrating this embodiment is illustrated in theflowchart of FIG. 7. The method for a process P1's semaphore systembegins at block 700 and continues to block 702 where it is determined ifthere is a conflict between process P1 and process P2 over a resource R.If there is a conflict, then it is determined whether P1 and P2 havebeen waiting an equal amount of time at block 704. If there is noconflict, then it is determined if the resource is locked by process P2at block 706.

[0045] If there is a conflict, and P1 and P2 have been waiting an equalamount of time, it is determined if P1's local priority is greater thanP2's local priority at block 712. If P1's local priority is greater thanP2's local priority, then access is granted to P1 at block 714.Otherwise access is denied to P1 at block 716.

[0046] If there is a conflict, and P1 and P2 have not been waiting anequal amount of time, it is determined if P1 has been waiting longer forthe resource R than P2 at block 708. If P1 has been waiting longer thanP2 for resource R, then access to resource R is granted to P1 at block714. Otherwise, access to resource R is denied to P1 at block 716.

[0047] If there is no conflict, then it is determined if the resource Ris locked by P2 at block 706, and if P2 has released its lock on R atblock 710. If R is locked by P2, and P2 has released its lock on R, thenaccess to resource R is granted to P1 at block 714. If R is locked andP2 has not released its lock on R, then PI is denied access to R atblock 716. If there is no conflict, and the resource R is not locked byP2, then access to resource R is granted to P1 at block 714. The methodends at block 718.

[0048] System Having Global Arbiter

[0049] In another embodiment of the invention, as illustrated in FIG. 8,the system 800 comprises a CPU having a plurality of processes 302, 304,306, and a memory comprising a plurality of resources 308, 310, 312,314, and a plurality of processes 302, 304, 306. In the system 300, eachprocess 302, 304, 306 has a corresponding semaphore system 316, 318, 320for managing shared access to the resources 308, 310, 312, 314.Alternatively, a single semaphore system 324 can be shared by allprocesses. Additionally, the system 800 comprises a global arbiter 802for resolving conflicts.

[0050] In the descriptions below, processes 302, 304, semaphore systems316, 318, and resource 308 are depicted to illustrate the arbitrationprocess for two processes and their corresponding semaphore systems fora given resource 308. However, one of ordinary skill in the art wouldunderstand that the descriptions apply process 306, semaphore system320, and resource 310, 312, 314, and any other processes, semaphoresystems, and resources that may be defined, but are not illustrated ordiscussed herein.

[0051] As illustrated in FIG. 9, a global arbiter 802 may comprise aqueue 900 (hereinafter “global priority queue”) having entries 902, 904,906, 908, 910, 912, 914, 916 where each entry corresponds to a priority,and each entry value indicates a unique process. (Alternatively, eachentry may correspond to a unique process, and the entry value indicatesthe priority of the process). Initially, each process is assigned to anentry in the queue having a priority value (where the entry value is theprocess identifier). As each process is granted access to a resource, itis moved to the bottom of the queue such that it has the lowestpriority.

[0052] A global arbiter 802 may comprise one queue for all resourcessuch that a first process P1 that is granted access over a secondprocess P2 subsequently has lower priority than P2 for all resources, orthe global arbiter 802 may comprise a plurality of queues eachcorresponding to a resource such that a first process P1 that is grantedaccess over a second process P2 subsequently has lower priority than P2for the given resource.

[0053] For purposes of illustration, the latter of the twoimplementations is discussed. However, it should be understood by one ofordinary skill in the art that either implementation will work.

Semaphore Comprising Local Arbiter Only

[0054] In one embodiment, as illustrated in FIG. 10, a semaphore system316, 318 may comprise the local arbiter 402, and each process 302, 304is assigned an initial priority in the global priority queue 900 of theglobal arbiter 802. The rankings change as the processes are grantedaccess to the resource 308.

[0055] A local arbiter 402 for a first process communicates with a localarbiter 402 for a second process to determine if there is a conflict. Ifthere is a conflict, the global arbiter 802 resolves the conflict bygiving the resource to the process with the higher global priority asdetermined by its global priority queue 900. For example, if process P1has a higher priority in the global priority queue than process P2, thenif processes P1 and P2 simultaneously request a given resource R, thenthe global arbiter grants access to the resource R to P1.

[0056] An example is illustrated in FIG. 11, where five (5) processesP1, P2, P3, P4, and P5 are at one time or another competing for a givenresource, R1. Assume that the global priority queue is initialized suchthat P1 has the highest priority and P5 initially has the lowestpriority (step 1). At step 2, P1 and P2 compete for R1 at the same time.Since P1 has higher priority than P2, P1 is granted access and thenmoved to the bottom of the queue in step 3.

[0057] At step 4, P4 and P5 compete for R1. Since P4 has higher prioritythan P5, P4 is granted access and moved to the bottom of the queue instep 5. At step 6, P1 and P4 compete for R1. Since P1 has higherpriority than P4, P1 is granted access and moved to the bottom of thequeue at step 7. At step 8, P2 and P1 compete for R1. Since P2 hashigher priority than P1, P2 is granted access and moved to the bottom ofthe queue. In this manner, it is apparent that fairness is achievedsince processes that have not been granted access to R1 have higherpriority than processes that have been granted access.

[0058] The method discussed above is illustrated in the flowchart ofFIG. 12. The method for a process P1's semaphore system begins at block1200 and continues to block 1202 where it is determined if there is aconflict between process P1 and process P2 over a resource R. If thereis a conflict, then it is determined if P1's global priority is greaterthan P2's global priority at block 1204. If P1's global priority isgreater than P2's global priority, then access is granted to P1 at block1208. Otherwise access is denied to P1 at block 1212.

[0059] If there is no conflict, then it is determined if the resource Ris locked by P2 at block 1206, and if P2 has released its lock on R atblock 1210. If R is locked by P2, and P2 has released its lock on R,then access to resource R is granted to P1 at block 1208. If R is lockedand P2 has not released its lock on R, then P1 is denied access to R atblock 1212. If there is no conflict, and the resource R is not locked byP2, then access to resource R is granted to P1 at block 1208. The methodends at block 1214.

Semaphore Comprising Local Arbiter and Timer Element

[0060] In another embodiment, as illustrated in FIG. 13, a semaphoresystem 316, 318 may comprise the local arbiter 402 and a timer element600 that keeps track of the time that its corresponding process haswaited for a given resource without locking, supra. Additionally, eachprocess is given an entry in the global priority queue 900 of the globalarbiter 802.

[0061] When multiple processes request the same resource, the localarbiter 402 for a first process P1 of the multiple processes resolves aconflict between PI and a second process P2 of the multiple processes,where P1 has higher priority than P2, as follows:

[0062] the local arbiter 402 will grant access to the process that hasbeen waiting longer, as determined by the timer element 600;

[0063] if both processes have been waiting the same amount of time, thenarbitration is offloaded to the global arbiter 802 to resolve theconflict.

[0064] Once arbitration has been offloaded to the global arbiter 802,the global arbiter 802 consults the global priority queue 900 todetermine which one of the two processes 302, 304 has higher priority.The global arbiter 802 then grants access to the process 302, 304 havingthe higher priority.

[0065]FIG. 14 illustrates this process. The method for a process P1'ssemaphore system begins at block 1400 and continues to block 1402 whereit is determined if there is a conflict between process P1 and processP2 over a resource R. If there is a conflict, then it is determinedwhether P1 and P2 have been waiting an equal amount of time at block1404. If there is no conflict, then it is determined if the resource islocked by process P2 at block 1406.

[0066] If there is a conflict, and P1 and P2 have been waiting an equalamount of time, it is determined if P1's global priority is greater thanP2's global priority at block 1412. If P1's global priority is greaterthan P2's global priority, then access is granted to P1 at block 1414.Otherwise access is denied to P1 at block 1416.

[0067] If there is a conflict, and P1 and P2 have not been waiting anequal amount of time, it is determined if P1 has been waiting longer forthe resource R than P2 at block 1408. If P1 has been waiting longer thanP2 for resource R, then access to resource R is granted to P1 at block1414. Otherwise, access to resource R is denied to P1 at block 1416.

[0068] If there is no conflict, then it is determined if the resource Ris locked by P2 at block 1406, and if P2 has released its lock on R atblock 1410. If R is locked by P2, and P2 has released its lock on R,then access to resource R is granted to P1 at block 1414. If R is lockedand P2 has not released its lock on R, then P1 is denied access to R atblock 1416. If there is no conflict, and the resource R is not locked byP2, then access to resource R is granted to P1 at block 1414. The methodends at block 1418.

[0069]FIG. 15 is a basic circuit diagram for implementing a localarbiter 402 as described in embodiments of the invention. Elements 1500and 1502 illustrate circuitry for determining whether any conflictexists. Element 1500 determines whether a first process P1 and a secondprocess P2 are requesting the same resource R, and element 1502determines if P1 is requesting a resource that P2 has locked. Element1504 accepts input from the global priority block to determine whichprocess has higher priority, and element 1506 accepts input from thetimer element to determine which process has been waiting longer.

[0070] For example, for a local arbiter 402 corresponding to a processP1, access to a resource R will be granted if:

[0071] P1 does not request the same resource as P2, and P1 does notrequest a resource that P2 has locked. This is represented by thecircuitry of FIG. 15 as follows:

[0072] If element 1532 is TRUE, then access to R is granted to P1. Ifelement 1532 is FALSE, then access to R is denied to P1. Element 1532 isTRUE if both elements 1508 and 1530 are TRUE.

[0073] Element 1508 generates a TRUE signal if P1 and P2 are notrequesting the same resource. Thus, if P1's request identifier does notequal P2's request identifier, then a TRUE signal is generated atelement 1508.

[0074] Element 1530 generates a TRUE signal if both elements 1526 and1528 generate a FALSE signal. Element 1528 generates a FALSE signal ifeither element 1512 or 1514 generates a FALSE signal. Thus, for example,element 1512 generates a FALSE signal if P1 does not request a resourcethat P2 has locked. Similarly, element 1526 generates a FALSE signal ifeither element 1510 or 1524 generates a FALSE signal. For example,element 1510 generates a FALSE signal if P1 does not request the sameresource that P2 requests—in other words, this generates the oppositesignal of element 1508.

[0075] P1 does not request the same resource as P2, P1 requests aresource that P2 has locked, but P2 releases that lock. This isrepresented by the circuitry as follows:

[0076] If element 1532 is TRUE, then access to R is granted to P1. Ifelement 1532 is FALSE, then access to R is denied to P1. Element 1532 isTRUE if both elements 1508 and 1530 are TRUE.

[0077] Element 1508 generates a TRUE signal if P1 and P2 are notrequesting the same resource. Thus, if P1's request identifier does notequal P2's request identifier, then a TRUE signal is generated atelement 1508.

[0078] Element 1528 generates a FALSE signal if either element 1512 or1514 generates a FALSE signal. Thus, for example, if element 1512generates a TRUE signal instead (because P1 requests a resource that P2has locked), then element 1514 must generate a FALSE signal. This occursif P2 releases its currently locked identifier. Similarly, element 1526generates a FALSE signal if either element 1510 or 1524 generates aFALSE signal. For example, element 1510 generates a FALSE signal if P1does not request the same resource that P2 requests—in other words, thisgenerates the opposite signal of element 1508.

[0079] P1 requests the same resource as P2, P1 is not requesting aresource that P2 as locked, (or if P1 has requested a resource that P2has locked, then P2 has released that lock), and P1 has waited longerfor the resource than P2. This is represented by the circuitry of FIG.15 as follows:

[0080] If element 1530 is TRUE, then access to R is granted to P1. Ifelement 1530 is FALSE, then access to R is denied to P1. Element 1530 isTRUE if both elements 1526 and 1528 are FALSE.

[0081] Element 1528 generates a FALSE signal if either element 1512 or1514 generates a FALSE signal. Thus, for example, element 1512 generatesa FALSE signal if P1 does not request a resource that P2 has locked.Also, if element 1512 generates a TRUE signal instead (because P1requests a resource that P2 has locked), then element 1514 must generatea FALSE signal. This occurs if P2 releases its currently lockedidentifier.

[0082] Since element 1510 generates a TRUE signal if P1 has requestedthe same resource as P2, element 1526 generates a FALSE signal under thefollowing circumstances. P1 and P2 have not been waiting the same amountof time, causing element 1518 to generate a FALSE signal, and therefore,causing element 1520 to generate a FALSE signal. Since P2 has not beenwaiting longer than P1, element 1522 generates a FALSE signal.Consequently, element 1524 generates a FALSE signal, and element 1526generates a FALSE signal. As a result, element 1530 generates a TRUEsignal, and P1 is granted access to R.

[0083] P1 requests the same resource as P2, P1 is not requesting aresource that P2 as locked, (or if P1 has requested a resource that P2has locked, then P2 has released that lock), P1 has waited for theresource equally as long as P2, and P1's global priority is greater thanP2's global priority. This is represented by the circuitry of FIG. 15 asfollows:

[0084] If element 1530 is TRUE, then access to R is granted to P1. Ifelement 1530 is FALSE, then access to R is denied to P1. Element 1530 isTRUE if both elements 1526 and 1528 are FALSE.

[0085] Element 1528 generates a FALSE signal if either element 1512 or1514 generates a FALSE signal. Thus, for example, element 1512 generatesa FALSE signal if P1 does not request a resource that P2 has locked.Also, if element 1512 generates a TRUE signal instead (because P1requests a resource that P2 has locked), then element 1514 must generatea FALSE signal. This occurs if P2 releases its currently lockedidentifier.

[0086] Since element 1510 generates a TRUE signal if P1 has requestedthe same resource as P2, element 1526 generates a FALSE signal only ifelement 1524 generates a FALSE signal. P1 and P2 have been waiting thesame amount of time, causing element 1518 to generate a TRUE signal.Since element 1518 is TRUE, element 1522 is necessarily FALSE. P2 doesnot have a higher priority than P1 so element 1516 is FALSE causingelement 1520 to be FALSE. This causes element 1524 to be FALSE, and,therefore, element 1526. As a result, element 1530 generates a TRUEsignal, and P1 is granted access to R.

CONCLUSION

[0087] Thus, an invention has been described for a semaphore system thatis based on process events rather than on resource events. In oneembodiment, the process event is a simple fixed priority. In anotherembodiment, the process event is a fairness-based dynamic priority.

[0088] In the foregoing specification, the invention has been describedwith reference to specific embodiments thereof. It will, however, beevident that various modifications and changes may be made theretowithout departing from the broader spirit and scope of the invention.The specification and drawings are, accordingly, to be regarded in anillustrative rather than a restrictive sense.

What is claimed is:
 1. A method comprising: requesting access to ashared resource for a first process having a first local priority;determining if a second process is simultaneously requesting access tothe shared resource, the second process having a second local priority;and if the second process is simultaneously requesting access to theshared resource, then granting access one of the first priority and thesecond priority having a higher local priority.
 2. The method of claim1, wherein the local priority is fixed for each of the first and thesecond process.
 3. The method of claim 1, additionally comprising if thesecond process is not simultaneously requesting access to the sharedresource, then: determining if the second process currently has a lockon the shared resource; if the second process currently has a lock onthe shared resource, then denying the first process access to the sharedresource; and if the second process does not have a lock on the sharedresource, then granting the first process access to the shared resource.4. A method comprising: requesting access to a shared resource for afirst process having a first local priority, and a first wait time;determining if a second process is simultaneously requesting access tothe shared resource, the second process having a second local priority,and a second wait time; if the second process is simultaneouslyrequesting access to the shared resource, then granting access to one ofthe first process and the second process having a longer wait time; andif the first wait time equals the second wait time, then granting accessto one of the first process and the second process having a local higherpriority.
 5. The method of claim 4, wherein the local priority is fixedfor each of the first and the second process.
 6. The method of claim 4,additionally comprising if the second process is not simultaneouslyrequesting access to the shared resource, then: determining if thesecond process currently has a lock on the shared resource; if thesecond process currently has a lock on the shared resource, then denyingthe first process access to the shared resource; and if the secondprocess does not have a lock on the shared resource, then granting thefirst process access to the shared resource.
 7. A method comprising:requesting access to a shared resource for a first process having afirst global priority on a global priority queue of a global arbiter;determining if a second process is simultaneously requesting access tothe shared resource, the second process having a second global priorityon the global priority queue of the global arbiter; and if the secondprocess is simultaneously requesting access to the shared resource, thengranting access to one of the first process and the second processhaving a higher global priority.
 8. The method of claim 7, wherein theglobal priority queue is one of a plurality of global priority queues inthe global arbiter, and each global priority queue corresponds to agiven shared resource.
 9. The method of claim 7, additionally comprisingif the second process is not simultaneously requesting access to theshared resource, then: determining if the second process currently has alock on the shared resource; if the second process currently has a lockon the shared resource, then denying the first process access to theshared resource; and if the second process does not have a lock on theshared resource, then granting the first process access to the sharedresource.
 10. A method comprising: requesting access to a sharedresource for a first process having a first global priority on a globalpriority queue of a global arbiter, and having a first wait time;determining if a second process is simultaneously requesting access tothe shared resource, the second process having a second global priorityon the global priority queue of the global arbiter, and having a secondwait time; if the second process is simultaneously requesting access tothe shared resource, then granting access to one of the first processand the second process having a longer wait time; and if the first waittime is equal to the second wait time, then granting access to one ofthe first process and the second process having a higher than globalpriority.
 11. The method of claim 10, wherein the global priority queueis one of a plurality of global priority queues in the global arbiter,and each global priority queue corresponds to a given shared resource.12. The method of claim 10, additionally comprising if the secondprocess is not simultaneously requesting access to the shared resource,then: determining if the second process currently has a lock on theshared resource; if the second process currently has a lock on theshared resource, then denying the first process access to the sharedresource; and if the second process does not have a lock on the sharedresource, then granting the first process access to the shared resource.13. An apparatus comprising: a local arbiter to arbitrate on behalf ofthe corresponding process for one of a plurality of resources; and asemaphore to indicate a status of the corresponding process.
 14. Theapparatus of claim 13, additionally comprising a local priority block toindicate a local priority of the corresponding process.
 15. Theapparatus of claim 13, additionally comprising a timer element todetermine a wait time for the corresponding process.
 16. A systemcomprising: one or more shared resources; and one or more processes,each corresponding to a semaphore system, and each semaphore systemhaving a local arbiter to arbitrate for access to a given one of theshared resources.
 17. The system as in claim 16, wherein a givensemaphore system additionally comprises a local arbiter block having alocal priority corresponding to a corresponding process, and the localarbiter arbitrates for access to a given one of the shared resources bygranting access to the corresponding process if its correspondingprocess has a local global priority than a conflicting process.
 18. Thesystem of claim 17, wherein the local priority is fixed.
 19. The systemas in claim 17, wherein the given semaphore system additionallycomprises a timer element, and the local arbiter arbitrates for accessto a given one of the shared resource by: granting access to thecorresponding process if the corresponding process waited longer for thegiven resource than the conflicting process; and if the correspondingprocess waited the same amount of time for the given resource as theconflicting process, then granting access to the corresponding processif the corresponding process has a higher local priority than theconflicting process.
 20. The system of claim 16, wherein the localarbiter arbitrates for access to a given one of the shared resources bygranting access to the corresponding process if there are no conflictingprocesses.
 21. The system as in claim 20, the system additionallycomprising a global arbiter having a global priority queue, the globalarbiter to: modify process priorities by moving processes that have beengranted access to a given resource to a position in the global priorityqueue having a lowest priority; and arbitrate conflicts between a firstprocess and a second process by granting access to one of the firstprocess and the second process having a having a higher global priority.22. The system of claim 16, wherein the semaphore additionally comprisesa timer element, and the local arbiter arbitrates for access to a givenone of the shared resources by: granting access to the correspondingprocess if the corresponding process waited longer for the givenresource than a conflicting process; and if the corresponding processhas waited the same amount of time for the given resource as theconflicting process, then offloading the arbitration process to a globalarbiter.
 23. The system as in claim 22, the system additionallycomprising the global arbiter having a global priority queue, the globalarbiter to: modify priorities to processes by moving processes that havebeen granted access to a given resource to a position in the globalpriority queue having a lowest priority; and arbitrate conflicts betweena first process and a second process by granting access to one of thefirst process and the second process having a higher priority.
 24. Amachine-readable medium having stored thereon data representingsequences of instructions, the sequences of instructions which, whenexecuted by a processor, cause the processor to perform the following:request access to a shared resource for a first process having a firstlocal priority; determine if a second process is simultaneouslyrequesting access to the shared resource, the second process having asecond local priority; and if the second process simultaneously requestsaccess to the shared resource, then grant access one of the firstpriority and the second priority having a higher local priority.
 25. Themachine-readable medium of claim 24, wherein the local priority is fixedfor each of the first and the second process.
 26. The machine-readablemedium of claim 24, additionally comprising if the second process is notsimultaneously requesting access to the shared resource, thenadditionally comprising sequences of instructions which, when executedby a processor, cause the processor to perform: determine if the secondprocess currently has a lock on the shared resource; if the secondprocess currently has a lock on the shared resource, then deny the firstprocess access to the shared resource; and if the second process doesnot have a lock on the shared resource, then grant the first processaccess to the shared resource.
 27. An apparatus comprising: at least oneprocessor; and a machine-readable medium having instructions encodedthereon, which when executed by the processor, are capable of directingthe processor to: request access to a shared resource for a firstprocess having a first local priority; determine if a second process issimultaneously requesting access to the shared resource, the secondprocess having a second local priority; and if the second processsimultaneously requests access to the shared resource, then grant accessone of the first priority and the second priority having a higher localpriority.
 28. The apparatus of claim 27, wherein the local priority isfixed for each of the first and the second process.
 29. The apparatus ofclaim 27, additionally comprising if the second process is notsimultaneously requesting access to the shared resource, thenadditionally encoded instructions which, when executed by a processor,are capable of causing the processor to: determine if the second processcurrently has a lock on the shared resource; if the second processcurrently has a lock on the shared resource, then deny the first processaccess to the shared resource; and if the second process does not have alock on the shared resource, then grant the first process access to theshared resource.
 30. An apparatus comprising: means for arbitrating onbehalf of the corresponding process for one of a plurality of resources;and means for indicating a status of the corresponding process.
 31. Theapparatus of claim 30, additionally comprising means for indicating alocal priority of the corresponding process.
 32. The apparatus of claim30, additionally comprising means for determining a wait time for thecorresponding process.